Skip to main content

Unique Paths

Question

None

Example 1
Input: m = 3, n = 2
Output: 3
Explanation:
From the top left corner, there are a total of 3 ways to reach the bottom right corner:
1. Right -> Right -> Down
2. Right -> Down -> Right
3. Down -> Right -> Right

Solution

all//Unique Paths.py


def uniquePaths(m, n):
if m == 1 or n == 1:
return 1
return uniquePaths(m-1, n) + uniquePaths(m, n-1)

m = 3
n = 3
print(uniquePaths(3, 3))